= errors_for app

%div.required
  = f.label :name
  = f.text_field :name

- unless app.new_record?
  %div
    %label Api Key
    %span= app.api_key
    = link_to t('.regenerate_api_key'), regenerate_api_key_app_path(app), :class => 'button', :method => 'post'
%div
  = f.label :repository_branch
  = f.text_field :repository_branch, :placeholder => "master"
%div
  = f.label :github_repo
  = f.text_field :github_repo, :placeholder => "errbit/errbit from https://github.com/errbit/errbit"
%div
  = f.label :bitbucket_repo
  = f.text_field :bitbucket_repo, :placeholder => "errbit/errbit from https://bitbucket.org/errbit/errbit"
%div
  = f.label :asset_host
  %em Used to generate links for JavaScript errors
  = f.text_field :asset_host, :placeholder => "e.g. https://assets.example.com"
%div
  = f.label :current_app_version, 'Latest App Version'
  %em Mobile apps can set this to ignore any error below this version. ie: 1.4.3
  = f.text_field :current_app_version, :placeholder => "e.g. 2.0.1 from the Bundle Identifier on an iOS app"
%fieldset
  %legend Notifications
  %div.checkbox
    = f.check_box :notify_on_errs, 'data-show-when-checked' => '.email_at_notices_nested'
    = f.label :notify_on_errs, 'Notify on errors'
  - if Errbit::Config.per_app_email_at_notices
    %div.email_at_notices_nested{:style => app_decorate.notify_err_display}
      .field-helpertext Send a notification every
      = f.text_field :email_at_notices, :value => app_decorate.email_at_notices
      .field-helpertext times an error occurs (comma separated).
  %div.checkbox
    = f.check_box :notify_on_deploys
    = f.label :notify_on_deploys, 'Notify on deploys'

%div.checkbox
  = f.check_box :notify_all_users
  = f.label :notify_all_users, 'Send notifications to all users'


%fieldset.watchers.nested-wrapper{:style => app_decorate.notify_user_display}
  %legend Watchers
  = f.fields_for :watchers do |w|
    %div.watcher.nested
      %div.choose
        = w.radio_button :watcher_type, :user
        = w.label :watcher_type_user, 'User'
        = w.radio_button :watcher_type, :email
        = label_tag :watcher_type_email, 'Email Address', :for => label_for_attr(w, 'watcher_type_email')
      %div.watcher_params.user{:class => w.object.email.blank? ? 'chosen' : nil}
        = w.select :user_id, users.map{|u| [u.name,u.id.to_s]}, :include_blank => '-- Select a User --'
      %div.watcher_params.email{:class => w.object.email.present? ? 'chosen' : nil}
        = w.text_field :email

%div.checkbox
  = f.check_box :resolve_errs_on_deploy
  = f.label :resolve_errs_on_deploy, 'Resolve errs on deploy'

= render "issue_tracker_fields", :f => f
= render "service_notification_fields", :f => f
